package com.douwong.student.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


public class DBHelper extends SQLiteOpenHelper {
	
	private static final String DB_NAME = "edouwong.db";
	private static final int BD_CURRECTVERSION = 1;

	private static final String CREATETABLE_USER = "create table user(id integer primary key autoincrement,account text,password text,ssoid text,"
			+ "autologin integer,role integer,createtime text)";
	private static final String CREATETABLE_CLASSFILE = "create table fileinfo(id integer primary key autoincrement,nickName text,fileName text,url1 text,url2 text,"
			+ "schoolId integer,createtime text,year integer,month integer,day integer,fileType integer,subject integer,folderId integer,suffix text)";
	private static final String CREATETABLE_MESSAGE = "create table class_message(id integer primary key autoincrement,messageType integer,identity integer,nickName text,creartTime text,"
			+ "content text,filePath text,fileSize text,photoPath text,userId text,isReaded integer,sendId text)";
	private static final String CREATETABLE_MESSAGE_FILE = "create table class_message_file(id integer primary key autoincrement,MessageSuffix text,MessageName text,MessagePath text,MessageTime text,"
			+ "NickName text,MessageType integer)";
	private static final String CREATETABLE_CLASS_SHARE_FILE = "create table class_share_file(id integer primary key autoincrement,upLoader text,fileSize text,fileName text,creatTime text,currentPro text,"
			+ "sendId text,isLoading integer,isLoaded integer,isPause integer,userId integer,filePath text,port integer,partCount integer,isShare integer,DataType integet,isExist integer)";
	private static final String CREATETABLE_CLSS_SHARE_LOADED="create table class_share_loaded(id integer primary key autoincrement,fileSize text,fileName text,creatTime text,userId integer,filePath text,sendId text)";
	// 答题记录数据库
	private static final String CREATEABLE_ANSWER_RECORD = "create table answer_record(id integer primary key autoincrement,TopicName text,TopicType text,"
			+ "TopicTeacher text,TopicTimes text,TopicStar text,filePath text,UserId text,StudentAnswer text,trueAnswer text,optionStr text,Correctrate text)";

	private static final String CREATETABLE_HAND_EXCHANGE = "create table hand_exchange(id integer primary key autoincrement,name text,subject text,createTime text,starCount integer,filePath,userId text)";
	private static final String CREATETABLE_PREPARE_RESOURCE = "create table prepare_resource(id integer primary key autoincrement,fileName text,fileSize integer,subject text,userName text,createTime text,currentPro integer,isLoading integer,isLoaded integer,isPause integer," +
			"userId text,suffixType integer,loadUrl text,attaKey text,filePath text,fileId integer,attaSuffix text)";
	private static final String CREATETABLE_PREPARE_LOADING = "create table prepare_load(id integer primary key autoincrement,fileName text,fileSize integer,subject text,userName text,createTime text,currentPro integer,isLoading integer,isLoaded integer,isPause integer," +
			"userId text,suffixType integer,loadUrl text,attaKey text,filePath text,isExist integer,fileId integer,totalSize integer,attaSuffix text,mcTitle text,loadTime text)";

	public DBHelper(Context context) {
		super(context, DB_NAME, null, BD_CURRECTVERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		Log.e("00000000", "创建数据库成功");
		db.execSQL(CREATETABLE_USER);
		db.execSQL(CREATETABLE_CLASSFILE);
		db.execSQL(CREATETABLE_MESSAGE);
		db.execSQL(CREATETABLE_MESSAGE_FILE);
		db.execSQL(CREATETABLE_CLASS_SHARE_FILE);
		db.execSQL(CREATETABLE_HAND_EXCHANGE);
		db.execSQL(CREATEABLE_ANSWER_RECORD);
		db.execSQL(CREATETABLE_PREPARE_RESOURCE);
		db.execSQL(CREATETABLE_PREPARE_LOADING);
		db.execSQL(CREATETABLE_CLSS_SHARE_LOADED);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

}
